//
//  DengJiJiFenViewController.m
//  YeDian
//
//  Created by Mac on 14-5-18.
//  Copyright (c) 2014年 Mac. All rights reserved.
//

#import "DengJiJiFenViewController.h"

#import "DengJiJiFenCell.h"

@interface DengJiJiFenViewController ()

@end

@implementation DengJiJiFenViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"等级和积分";
    [self initData];
}
- (IBAction)backButAction:(id)sender {
    
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)initData{
    
    if (!_dataArr) {
        self.dataArr = [NSMutableArray arrayWithCapacity:0];
    }
    NSArray *nameArr1 = @[@"1-5级",@"6-10级",@"10-15级",@"16-20级",@"21-25级",@"26-30级",@"31-35级",@"36-40级",@"41-45级"];
    NSArray *valueArr1 = @[@"每级需要50积分",@"每级需要100积分",@"每级需要200积分",@"每级需要300积分",@"每级需要400积分",@"每级需要500积分",@"每级需要600积分",@"每级需要800积分",@"每级需要1000积分"];
    
    NSMutableArray *arr1 = [@[] mutableCopy];
    for (int i = 0;i<nameArr1.count;i++) {
        NSDictionary *dic = @{@"name":nameArr1[i],@"jifen":@"",@"des":valueArr1[i]};
        [arr1 addObject:dic];
    }
    [_dataArr addObject:arr1];
    
    
    NSArray *nameArr2 = @[@"完善基本资料",@"完善名片设置",@"完善审核通过",@"每日登录",@"发表动态",@"评论他人",@"签到",@"礼物赠送",@"收到礼物"];
    NSArray *valueArr2 = @[@"第一次有效",@"第一次有效",@"第一次有效",@"第一次有效",@"第一次有效",@"第一次有效",@"第一次有效",@"",@""];
    NSArray *jifenArr = @[@"+10",@"+30",@"+10",@"+10",@"+10",@"+10",@"+10",@"+10",@"+5"];
    
    NSMutableArray *arr2 = [@[] mutableCopy];
    for (int i = 0;i<nameArr2.count;i++) {
        NSDictionary *dic = @{@"name":nameArr2[i],@"jifen":jifenArr[i],@"des":valueArr2[i]};
        [arr2 addObject:dic];
    }
    [_dataArr addObject:arr2];

    [_table reloadData];
    
}



- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - table

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return _dataArr.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return ((NSArray *)_dataArr[section]).count;
}


- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    
    if (section==0) {
        return @"等级与积分";
    }
    else{
        
        return @"如何获得积分";
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    DengJiJiFenCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DengJiJiFenCell" forIndexPath:indexPath];
    NSDictionary *dic = [_dataArr[indexPath.section] objectAtIndex:indexPath.row];
    cell.nameLab.text = [dic objectForKey:@"name"];
    cell.jiFenLab.text = [dic objectForKey:@"jifen"];
    cell.desLab.text = [dic objectForKey:@"des"];
    return cell;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
